package com.rtf.framework.monitor.rest;

import com.rtf.framework.monitor.AppMonitorDefaultEndpoint;
import com.rtf.framework.monitor.config.AppMonitorProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@RequestMapping("/api")
public class AppMonitorController {

    private AppMonitorDefaultEndpoint appMonitorEndpoint = new AppMonitorDefaultEndpoint() ;

    @Autowired
    private AppMonitorProperties appMonitorProperties ;

    @ResponseBody
    @RequestMapping(value = "/monitor" , produces = "text/plain")
    public String scrapeMonitor(){
        return appMonitorEndpoint.scrape( appMonitorProperties.getMetrics() , null ) ;
    }

}
